package net.wenku8.reader.view.common

import androidx.compose.material3.AlertDialog
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.window.DialogProperties
import androidx.lifecycle.viewmodel.compose.viewModel
import net.wenku8.reader.ui.lite.LiteText
import net.wenku8.reader.ui.lite.LiteTitle

@Composable
fun DialogLayer(){
    val dialogViewModel = viewModel<DialogViewModel>()
    if (dialogViewModel.show){
        AlertDialog(
            onDismissRequest = { dialogViewModel.show = false },
            text = {
                LiteText(dialogViewModel.text, maxLines = 10)
            },
            confirmButton = {
            },
            dismissButton = {
                TextButton(onClick = { dialogViewModel.show = false }) {
                    LiteText("关闭")
                }
            },
            properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false)
        )
    }
}